const KEY = 'token'

// 保存 token
export const setToken = (data) => {
  localStorage.setItem(KEY, JSON.stringify(data))
}

// 获取 token
export const getToken = () => {
  const data = localStorage.getItem(KEY)
  try {
    return JSON.parse(data)
  } catch (error) {
    return data
  }
}

export const removeToken = () => {
  localStorage.removeItem(KEY)
}
